#include"processBar.h"
#include<unistd.h>

typedef void (*callback_t)(int);

void download(callback_t cb)
{
	int total = 1000;
	int cur = 0;

	while(cur <= total)
	{
		usleep(50000);//模拟下载时间
		
		int rate = cur*100/total;
		cb(rate);
		cur += 10;
	}
	printf("\n");
}




int main()
{
	printf("download1:\n");
	download(processBar);
	initBar();
	printf("download2:\n");
	download(processBar);
	initBar();
	printf("download3:\n");
	download(processBar);
	initBar();
	printf("download4:\n");
	download(processBar);
	initBar();
//  processBar(50000);
//  int count = 10;
//  while(count>=0)
//  {
//      printf("%-2d\r",count);
//      fflush(stdout);
//      sleep(1);
//      count--;
//  }
// 	printf("\n");
 return 0;
}
